﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include <QtWidgets/QWidget>

class QLabel;
class QCheckBox;

namespace gnuf {
    class Pallet;
    class QtPalletButton;
    class QtPalletCheckBox;

    class GNUF_BASE_EXPORT QtPalletFooter final : public QWidget
    {
        Q_OBJECT
    public:
        QtPalletFooter(Pallet *);
        virtual ~QtPalletFooter();

        int indexOf(const QtPalletButton *) const;
        void switchQtButton();
        void click(QtPalletButton *);
        void stateChanged(QtPalletCheckBox *, bool bChecked);
        Pallet * pallet() { return m_wpPallet.Get(); }
        const Pallet* pallet() const { return m_wpPallet.Get(); }

        void setCurrentQtButton(size_t buttonIndex);

        void refresh();
        std::vector<gcmp::OwnerPtr<QtPalletButton>>& rawButtons();
    signals:
        void onClose();

    private:
        void setStyle();
        void setCurrentQtButton(QtPalletButton *);

        gcmp::WeakPtr<Pallet> m_wpPallet;
        QtPalletButton* m_currentQtButton;
        QLabel* m_pTextLabel;
        gcmp::OwnerPtr<QtPalletCheckBox> m_pCheckBox;
        std::vector<gcmp::OwnerPtr<QtPalletButton>> m_qtButtons;
    };
}
